import math

class statFuncs:
	
	def computeSD(self, data):
		sum		= 0.0
		mean	= self.computeMean(data)
		for item in data:
			sum	= sum + math.pow(float(item) - mean, 2)

		return math.sqrt(sum/len(data))

	def computeMean(self, data):
		sum	= 0.0
		for item in data:
			sum	= sum + float(item)

		return sum/len(data)

	def movingAvg(self, data, factor):
		avg		= []
		count	= 0
		sum		= 0.0

		for i in range(0, factor):
			sum	= sum + float(data [i])
		avg.append(sum/float(factor))

		for i in range(factor, len(data)):
			sum		= sum + float(data [i]) - float(data [i-factor])
			avg.append(sum/float(factor))

		return avg
